import BaseSprite from "../../Base/BaseSprite";

const { ccclass, property } = cc._decorator;

@ccclass
export class ItemToast extends BaseSprite {

    @property({ type: cc.Node, tooltip: "toast底框" })
    private toast: cc.Node = null;

    @property({ type: cc.Label, tooltip: "描述(label)" })
    private label: cc.Label = null;

    @property({ type: cc.RichText, tooltip: "描述(richText)" })
    private richText: cc.RichText = null;

    public setLabel(toast: string, isRt: boolean) {
        this.label.node.active = !isRt;
        this.richText.node.active = isRt;
        this.label.string = `${toast}`;
        this.richText.string = `${toast}`;
    }

    protected update(dt: number): void {
        // 赋值完文本高度不变, 需要等一帧
        this.toast.height = this.label.node.height + 20;
    }
}